package net.majodali.glasshouse.javacode;

import java.io.File;
import java.io.PrintStream;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Set;

public class ClassDefinition {
	private String className;
	private Class<?> superclass;
	private Set<Class<?>> interfaces = new HashSet<Class<?>>();
	private int modifiers;
	private Set<FieldDefinition> fields = new LinkedHashSet<FieldDefinition>();
	private Set<MethodDefinition> methods = new LinkedHashSet<MethodDefinition>();
	
	public ClassDefinition setClassName(String name) {
		this.className = name;
		return this;
	}

	public ClassDefinition addInterfaces(Class<?>...ifaces) {
		return addInterfaces(Arrays.asList(ifaces));
	}

	public ClassDefinition addInterfaces(Collection<Class<?>> ifaces) {
		interfaces.addAll(ifaces);
		return this;
	}

	public ClassDefinition setSuperclass(Class<?> superclass) {
		this.superclass = superclass;
		return this;
	}

	public ClassDefinition setModifiers(int mods) {
		modifiers = mods;
		return this;
	}

	public ClassDefinition useMethod(MethodDefinition method) {
		//methods.add(method.setOwner(this));
		return this;
	}

	public MethodDefinition addMethod(String name) {
		MethodDefinition method = new MethodDefinition(this, name);
		methods.add(method);
		return method;
	}

	public ClassDefinition useField(FieldDefinition field) {
		//fields.add(field.setOwner(this));
		return this;
	}

	public FieldDefinition addField(String name) {
		FieldDefinition field = new FieldDefinition(this, name);
		fields.add(field);
		return field;
	}
	
	public void writeClass(PrintStream out) {
		
	}
}
